import request from '../utils/request';

// 查询公众号账户列表接口
export async function queryAccountList() {
  return request('/api/accounts/get_accounts');
}

// 搜索账号
export async function queryAccount(params) {
  return request('/api/accounts/get_account', {
    method: 'POST',
    body: {
      key: params,
    },
  });
}

// 添加公众号账号
export async function setAccount(params) {
  return request('/api/accounts/set_account', {
    method: 'POST',
    body: params,
  });
}

// 更新公众号
export async function updateAccount(params) {
  return request('/api/accounts/update_account', {
    method: 'POST',
    body: params,
  });
}

// 获取指定公众号
export async function getOne(params) {
  return request(`/api/accounts/get/id/${params}`);
}

// 删除公众号
export async function removeAccount(params) {
  return request(`/api/accounts/del_account/id/${params}`);
}

// 查询指定公众号下的模板消息列表接口
export async function queryTmpList(params) {
  return request(`/api/templates/get_templates/id/${params}`);
}

//  创建一个新任务接口
export async function setSchedule(params) {
  return request('/api/templates/set_schedule', {
    method: 'POST',
    body: params,
  });
}

// 获取定时任务列表
export async function queryTask() {
  return request('/api/task/query');
}

// 删除定时任务
export async function deleteTask(params) {
  return request(`api/task/delete/job_id/${params}`);
}

// 获取已授权的授权方列表
export async function getAuthorizerList() {
  return request('wechat/index/get_authorizer_list');
}

// 查询授权方
export async function getAuthorizer(params) {
  return request(`wechat/index/get_authorizer/keyword/${params}`);
}

// 获取授权url
export async function getPreAuthUrl() {
  return request('wechat/index/get_preauth_url');
}

// 获取某个授权方的所有素材列表
export async function getMediaList(params) {
  return request('wechat/customer/get_media_id/appid', {
    method: 'POST',
    body: params,
  });
}

// 发送素材客服消息人物
export async function sendMediaMsgSchedule(params) {
  return request('wechat/customer/send_media_msg_schedule', {
    method: 'POST',
    body: params,
  });
}

// 发送文本客服消息任务
export async function sendTextMsgSchedule(params) {
  return request('wechat/customer/send_text_msg_schedule', {
    method: 'POST',
    body: params,
  });
}

// 发送图片链接消息任务
export async function sendImgUrlMsgSchedule(params) {
  return request('wechat/customer/send_img_url_msg_schedule', {
    method: 'POST',
    body: params,
  });
}

// 获取客服消息定时任务列表
export async function queryCustomerTask() {
  return request('wechat/task/query');
}

// 查询小程序列表
export async function queryXcxList() {
  return request('api/sendtmp/get_xcx');
}

// 查询小程序模板消息
export async function queryXcxTmpList(params) {
  return request(`api/sendtmp/get_tmp_list/appid/${params}`);
}

// 设置发送小程序模板消息任务
export async function setXcxSchedule(params) {
  return request('api/sendtmp/set_schedule', {
    method: 'POST',
    body: params,
  });
}
